//
//  CAReturnStatusView.m
//  LNH
//
//  Created by twentylx on 2018/2/24.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAReturnStatusView.h"
#import "UITextView+CAPlaceholder.h"

@implementation CAReturnStatusView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    self.backgroundColor = [UIColor clearColor];
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.orderStatusView];
    [self.orderStatusView addSubview:self.orderStatusLabel];
    [self.orderStatusView addSubview:self.orderStatusSelectLabel];
    [self.orderStatusView addSubview:self.orderStatusMoreImageView];
    
    [self addSubview:self.returnReasonView];
    [self.returnReasonView addSubview:self.returnReasonLabel];
    [self.returnReasonView addSubview:self.returnReasonSelectLabel];
    [self.returnReasonView addSubview:self.returnReasonMoreImageView];
    
    [self addSubview:self.returnPriceView];
    [self.returnPriceView addSubview:self.returnPriceNameLabel];
    [self.returnPriceView addSubview:self.returnPriceLabel];
    
    [self addSubview:self.returnSpeakTextView];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [self.orderStatusView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self);
        make.height.mas_equalTo(44);
    }];
    
    [_orderStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.orderStatusView).offset(20);
        make.centerY.equalTo(self.orderStatusView);
    }];
    
    [_orderStatusSelectLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.orderStatusMoreImageView.mas_left).offset(-10);
        make.centerY.equalTo(self.orderStatusView);
    }];
    
    [_orderStatusMoreImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.orderStatusView).offset(-20);
        make.centerY.equalTo(self.orderStatusView);
    }];
    
    [_returnReasonView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.orderStatusView.mas_bottom).offset(5);
        make.height.mas_equalTo(44);
    }];
    
    [_returnReasonLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.returnReasonView).offset(20);
        make.centerY.equalTo(self.returnReasonView);
    }];
    
    [_returnReasonSelectLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.returnReasonMoreImageView.mas_left).offset(-10);
        make.centerY.equalTo(self.returnReasonView);
    }];
    
    [_returnReasonMoreImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.returnReasonView).offset(-20);
        make.centerY.equalTo(self.returnReasonView);
    }];
    
    [_returnPriceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.returnReasonView.mas_bottom).offset(5);
        make.height.mas_equalTo(44);
    }];
    
    [_returnPriceNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.returnPriceView).offset(20);
        make.centerY.equalTo(self.returnPriceView);
    }];
    
    [_returnPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.returnPriceView).offset(-20);
        make.centerY.equalTo(self.returnPriceView);
    }];
    
    [_returnSpeakTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.returnPriceView.mas_bottom).offset(5);
        make.height.mas_equalTo(80);
    }];
}

#pragma mark get & set
- (UIView *)orderStatusView {
    if (!_orderStatusView) {
        _orderStatusView = [UIView new];
        _orderStatusView.backgroundColor = [UIColor whiteColor];
    }
    return _orderStatusView;
}

- (UILabel *)orderStatusLabel {
    if (!_orderStatusLabel) {
        _orderStatusLabel = [UILabel new];
        _orderStatusLabel.text = @"货物状态";
        _orderStatusLabel.textColor = RGBCOLOR(35, 24, 21);
        _orderStatusLabel.font = [UIFont systemFontOfSize:16];
    }
    return _orderStatusLabel;
}

- (UILabel *)orderStatusSelectLabel {
    if (!_orderStatusSelectLabel) {
        _orderStatusSelectLabel = [UILabel new];
        _orderStatusSelectLabel.text = @"请选择";
        _orderStatusSelectLabel.textColor = RGBCOLOR(136, 136, 136);
        _orderStatusSelectLabel.font = [UIFont systemFontOfSize:16];
        _orderStatusSelectLabel.textAlignment = NSTextAlignmentRight;
    }
    return _orderStatusSelectLabel;
}

- (UIImageView *)orderStatusMoreImageView {
    if (!_orderStatusMoreImageView) {
        _orderStatusMoreImageView = [UIImageView new];
        _orderStatusMoreImageView.image = LMImageNamed(@"more");
    }
    return _orderStatusMoreImageView;
}
//退货原因
- (UIView *)returnReasonView {
    if (!_returnReasonView) {
        _returnReasonView = [UIView new];
        _returnReasonView.backgroundColor = [UIColor whiteColor];
    }
    return _returnReasonView;
}

- (UILabel *)returnReasonLabel {
    if (!_returnReasonLabel) {
        _returnReasonLabel = [UILabel new];
        _returnReasonLabel.text = @"退款原因";
        _returnReasonLabel.textColor = RGBCOLOR(35, 24, 21);
        _returnReasonLabel.font = [UIFont systemFontOfSize:16];
    }
    return _returnReasonLabel;
}

- (UILabel *)returnReasonSelectLabel {
    if (!_returnReasonSelectLabel) {
        _returnReasonSelectLabel = [UILabel new];
        _returnReasonSelectLabel.text = @"请选择";
        _returnReasonSelectLabel.textColor = RGBCOLOR(136, 136, 136);
        _returnReasonSelectLabel.font = [UIFont systemFontOfSize:16];
        _returnReasonSelectLabel.textAlignment = NSTextAlignmentRight;
    }
    return _returnReasonSelectLabel;
}

- (UIImageView *)returnReasonMoreImageView {
    if (!_returnReasonMoreImageView) {
        _returnReasonMoreImageView = [UIImageView new];
        _returnReasonMoreImageView.image = LMImageNamed(@"more");
    }
    return _returnReasonMoreImageView;
}
//价格
- (UIView *)returnPriceView {
    if (!_returnPriceView) {
        _returnPriceView = [UIView new];
        _returnPriceView.backgroundColor = [UIColor whiteColor];
    }
    return _returnPriceView;
}

- (UILabel *)returnPriceNameLabel {
    if (!_returnPriceNameLabel) {
        _returnPriceNameLabel = [UILabel new];
        _returnPriceNameLabel.text = @"退款金额";
        _returnPriceNameLabel.textColor = RGBCOLOR(35, 24, 21);
        _returnPriceNameLabel.font = [UIFont systemFontOfSize:16];
    }
    return _returnPriceNameLabel;
}

- (UILabel *)returnPriceLabel {
    if (!_returnPriceLabel) {
        _returnPriceLabel = [UILabel new];
        _returnPriceLabel.text = @"￥399.00";
        _returnPriceLabel.textColor = RGBCOLOR(136, 136, 136);
        _returnPriceLabel.font = [UIFont systemFontOfSize:16];
        _returnPriceLabel.textAlignment = NSTextAlignmentRight;
    }
    return _returnPriceLabel;
}

- (UITextView *)returnSpeakTextView {
    if (!_returnSpeakTextView) {
        _returnSpeakTextView = [UITextView new];
        _returnSpeakTextView.ca_placeholder = @"退货说明：选填";
        _returnSpeakTextView.ca_placeholderColor = RGBCOLOR(178, 178, 178);
        _returnSpeakTextView.textContainerInset =  UIEdgeInsetsMake(5, 20, 0, 0);
        _returnSpeakTextView.font = [UIFont systemFontOfSize:16];
    }
    return _returnSpeakTextView;
}

@end
